
use "Mturk.dta"

*Survey time var
gen length_milsec=v9-v8
gen length_sec=(v9-v8)/1000
gen length_min=(v9-v8)/60000

*Drop unfinished survey 
drop if v10==0

*Drop surveys less than 4 mins
drop if length_min<4

*Drop IP address
drop v6

rename q211_1 sanders_control
rename q211_2 clinton_control
rename q211_3 warren_control
rename q211_4 cruz_control
rename q211_5 trump_control
 
rename q213_1 sanders_treat
rename q213_2 clinton_treat
rename q213_3 warren_treat
rename q213_4 cruz_treat
rename q213_5 trump_treat
 
rename q214 wt1worry
rename q215_0 wt1anger

gen treat_worry=wt1worry
recode treat_worry 1/5=1 *=0
gen treat_anger=wt1anger
recode treat_anger 1/5=1 *=0

*create combnied variables
egen sanders=rowmax(sanders_control sanders_treat)
label variable sanders "Sanders Thermometer" 
egen clinton=rowmax(clinton_control clinton_treat)
label variable clinton "Clinton Thermometer" 
egen cruz=rowmax(cruz_control cruz_treat)
label variable cruz "Cruz Thermometer" 
egen trump=rowmax(trump_control trump_treat)
label variable trump "Trump Thermometer" 

*create tt variable
gen treat_tt=q212_1
recode treat_tt .=0

*create tt_worry&anger measures
gen treat_worryfirst=0
recode treat_worryfirst 0=1 if treat_tt==1 & treat_worry==1
label variable treat_worryfirst "Worry about Terrorism asked first"
gen treat_angerfirst=0
recode treat_angerfirst 0=1 if treat_tt==1 & treat_anger==1
label variable treat_angerfirst "Anger about Terrorism asked first"


*generate partisanship dummmies
gen republican=0
recode republican 0=1 if q226==1
gen democrat=0
recode democrat 0=1 if q226==2

*gen gender
gen female=q1
recode female 2=1 1=0



*gen worry “very” or “somewhat” dummy (distribution=4.41%=very worried, 18.46% somewhat; 35.54% a little; 28.37% not at all; 13.22% haven’t thought about it much
recode wt1worry 1=1 2=1 3/5=0, gen(wt1worrymuch)


*** Figure 2 ***
eststo clinton: reg clinton treat_worryfirst if treat_angerfirst == 0
eststo trump: reg trump treat_worryfirst if treat_angerfirst == 0
eststo sanders: reg sanders treat_worryfirst if treat_angerfirst == 0
eststo cruz: reg cruz treat_worryfirst if treat_angerfirst == 0

coefplot (clinton, label (Clinton)) (sanders, label (Sanders)) (trump, label (Trump)) (cruz, label (Cruz)) ///
	||, drop(_cons) vertical yline(0) ytitle ("Feeling Thermometer") title ("")  legend (rows(1) pos(6)) saving (all_candidates, replace)  
	graph export "all_candidates.tif", as(tif) replace

	
eststo clear

*** Appendix Table 5
eststo clinton: reg clinton treat_worryfirst treat_angerfirst
eststo trump: reg trump treat_worryfirst treat_angerfirst

esttab using Table5.rtf, replace nogap se b(%9.2f) starlevels(^ .10 * .05 ** .01 *** .001) r2(%9.2f) ///
title("Appendix Table 5 Question Wording Effects on Feeling Thermometer") nonumber label

eststo clear
